import React, { useCallback, useRef } from "react";
import { Button } from "antd";
import useRecord from "./useRecord";
export default () => {
    const videoRef = useRef<HTMLVideoElement>(null);
    const switchRecordState = () => {
        onStart()
    }
    const stopRecordState = () => {
        onStop()
    }
    const handleRecording = useCallback((stream: MediaStream, sampleRate: number) => {
        const video = document.createElement("video");
        video.srcObject = stream;
        video.play()
    }, [])
    const {onStart, onStop} = useRecord({recordCallback: handleRecording})
    return (
        <>
            <Button onClick={switchRecordState}>开始录音</Button>
            <Button onClick={stopRecordState}>停止录音</Button>
        </>
    )
}